#include <stdio.h>

#define N 5

int main(void) {
	int array[N][N] = { 0 }, row_total[N] = { 0 }, col_total[N] = { 0 };

	for (int i = 0; i < N; i++)
	{
		printf("Enter row %d: ", i + 1);
		for (int j = 0; j < N; j++)
		{
			scanf("%d", &array[i][j]);
		}
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			row_total[i] += array[i][j];
			col_total[j] += array[i][j];
		}
	}

	printf("\nRow totals: ");
	for (int i = 0; i < N; i++)
	{
		printf("%d ", row_total[i]);
	}

	printf("\nColumn totals: ");
	for (int i = 0; i < N; i++)
	{
		printf("%d ", col_total[i]);
	}
	printf("\n");
    return 0;
}
